FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block mariadb_base_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{{ macros.configure_user(name='mysql') }}

{{ macros.enable_extra_repos(['mariadb']) }}

{% if base_package_type == 'rpm' %}
    {% set mariadb_base_packages = [
        'mariadb',
    ] %}

{% elif base_package_type == 'deb' %}
    {% set mariadb_base_packages = [
        'mariadb-client',
    ] %}
{% endif %}

{{ macros.install_packages(mariadb_base_packages | customizable("packages")) }}

{# NOTE(mnasiadka): Latest clustercheck version as of May 2023 is 10.9 #}
{% block mariadb_clustercheck_version %}
ARG mariadb_clustercheck_version=10.9
ARG mariadb_clustercheck_url=https://src.fedoraproject.org/rpms/mariadb/raw/${mariadb_clustercheck_version}/f/clustercheck.sh
{% endblock %}

RUN curl -o /usr/bin/clustercheck ${mariadb_clustercheck_url} \
    && chmod 755 /usr/bin/clustercheck

{% block mariadb_base_footer %}{% endblock %}
